﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using WpfApp001.Core;
using WpfApp001.Model;

namespace WpfApp001.ViewModel
{
    public class MainViewVM : NotifyBase
    {
		private UserModel userInfo;

		public UserModel UserInfo
		{
			get { return userInfo; }
			set { userInfo = value; }
		}


		private string searchText;

		public string SearchText
		{
			get { return searchText; }
			set { searchText = value;this.DoNotify(); }
		}

		private FrameworkElement mainContent;

		public FrameworkElement MainContent
		{
			get { return mainContent; }
			set { mainContent = value; this.DoNotify(); }
		}


		public CommandBase NavChangeCommand { get; set; }

		public MainViewVM()
		{
			this.MainContent = new WpfApp001.UserControls.Home();
            this.UserInfo = new UserModel();
			this.NavChangeCommand = new CommandBase();
			this.NavChangeCommand.DoExecute = new Action<object>(DoNavChanges);
			this.NavChangeCommand.DoCanExecute = new Func<object, bool>(o => true);
        }

		private void DoNavChanges(object param)
		{
			Type type = Type.GetType("WpfApp001.UserControls."+param.ToString());
			ConstructorInfo constructorInfo = type.GetConstructor(System.Type.EmptyTypes);
			this.MainContent = (FrameworkElement)constructorInfo.Invoke(null);

        }

	}
}
